package com.hui.web.servlet.roomServlet;

import com.hui.service.IRecordService;
import com.hui.service.impl.RecordServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "RoomRecordExecuteServlet",urlPatterns = "/room/record/execute")
public class RoomRecordExecuteServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String recordId = request.getParameter("recordId");
        String roomId = request.getParameter("roomId");
        IRecordService recordService=new RecordServiceImpl();
        recordService.processRecord(Integer.parseInt(recordId),Integer.parseInt(roomId));
        response.sendRedirect("/room/record/index?roomId="+roomId);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
